// MainDlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,
		public CMessageFilter, public CIdleHandler
{
public:
	enum { IDD = IDD_MAINDLG };

	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnIdle();

	BEGIN_UPDATE_UI_MAP(CMainDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
		MESSAGE_HANDLER(WM_XBUTTONDOWN, OnXButtonDown)
		COMMAND_ID_HANDLER(IDOK, OnOK)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		COMMAND_HANDLER(IDC_BTN_NEW, BN_CLICKED, OnBnClickedBtnNew)
		COMMAND_HANDLER(IDC_BTN_OPTIMIZE, BN_CLICKED, OnBnClickedBtnOptimize)
		COMMAND_HANDLER(IDC_BTN_EXPORT, BN_CLICKED, OnBnClickedBtnExport)
		COMMAND_HANDLER(IDC_BTN_REMOVE, BN_CLICKED, OnBnClickedBtnRemove)
		NOTIFY_HANDLER(IDC_LST_FILES, NM_DBLCLK, OnNMDblclkLstFiles)
		COMMAND_HANDLER(IDC_BTN_FOLDER, BN_CLICKED, OnBnClickedBtnFolder)
		COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnBnClickedCancel)
		COMMAND_HANDLER(IDC_RDO_STOREPURE, BN_CLICKED, OnBnClickedRdoStorePure)
		COMMAND_HANDLER(IDC_RDO_STOREAUTO, BN_CLICKED, OnBnClickedRdoStoreAuto)
	END_MSG_MAP()

	//--
	CString m_deftitle;
	CString m_exppath;

	CString m_oo;
	tpl::BlueStr<MAX_PATH> m_filename;
	kHfs* m_hfs;
	kint m_store;

	tpl::HashTable<const char*, bool, tpl::HashCharPtr, tpl::EqToCharPtr> m_htext;

	CButton m_btnExport;
	CButton m_btnRemove;
	CButton m_btnOptimize;
	CButton m_btnNew;
	CButton m_btnFolder;
	CButton m_chkLower;
	CEdit m_edtFile;
	CListViewCtrl m_lstFiles;
	CButton m_rdoStorePure;
	CButton m_rdoStoreAuto;
	CButton m_chkExtension;
	//--

	//==
	void ResetHfs();
	bool LoadHfs(const kwchar* filename);
	bool OpenHfs(const char* filename);
	void SetHfsDir(const char* dir = ".", bool showerror = true);
	bool CheckExtension(const char* filename);
	void ExportHfsDir(const char* dir, const kwchar* outdir);
	//==

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnDropFiles(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnXButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	void CloseDialog(int nVal);
	LRESULT OnBnClickedBtnNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedBtnOptimize(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedBtnExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedBtnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnNMDblclkLstFiles(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);
	LRESULT OnBnClickedBtnFolder(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedRdoStoreAuto(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);;
	LRESULT OnBnClickedRdoStorePure(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
};
